<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>MeshSupport</title>
  <link rel="shortcut icon" type="image/x-icon" href="/examples/public/favicon.ico" >
  <link rel="stylesheet" href="../css/common.css">
</head>

<style>
  #app {
    width: 100%;
    height: 100%;
  }

</style>

<body>
  <div id="app"></div>

  <script type="module">
    import * as THREE from 'three'
    import * as Vis from '../../dist/Vis.es.js'
    import { v4 as getUUid } from 'uuid'

    const canvasTextureGenerator = new Vis.CanvasTextureGenerator({
      width: 256,
      height: 256
    }).draw(ctx => {
      ctx.textBaseline = 'middle'
      ctx.textAlign = "center"

      ctx.fillStyle= 'rgb(206, 42, 230)'
   
      ctx.font=" bold 72px 微软雅黑"
      ctx.fillText("MESH", 128, 128)
    }).preview()

    const engine = new Vis.ModelingEngineSupport()
    .setDom(document.getElementById('app'))
    .setSize()
    .setStats(true)
    .play()
    .registerResources({
      'example.canvasTexture': canvasTextureGenerator.get()
    })


    const pointLight = Vis.generateConfig('PointLight', {
      position: {
        x: 30,
        y: 50
      },
      distance: 100
    })
    engine.dataSupportManager.lightDataSupport.getData()[pointLight.vid] = pointLight

    
    const canvasTexture = Vis.generateConfig('CanvasTexture', {
      url: 'example.canvasTexture',
    })
    engine.dataSupportManager.textureDataSupport.getData()[canvasTexture.vid] = canvasTexture


    const material = Vis.generateConfig('MeshStandardMaterial', {
      map: canvasTexture.vid,
    })
    engine.dataSupportManager.materialDataSupport.getData()[material.vid] = material


    const geometry = Vis.generateConfig('BoxGeometry', {
      width: 20,
      height: 10,
      depth: 20
    })
    engine.dataSupportManager.geometryDataSupport.getData()[geometry.vid] = geometry


    const mesh = Vis.generateConfig('Mesh', {
      material: material.vid,
      geometry: geometry.vid
    })

    engine.dataSupportManager.meshDataSupport.getData()[mesh.vid] = mesh
  </script>
  
</body>
</html>